package com.example.my.meila.common.image;

import android.content.Context;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.example.my.meila.R;

import jp.wasabeef.glide.transformations.RoundedCornersTransformation;


/**
 * Created by My on 2016/10/13.
 */
public class ImageLoader {
    private static volatile ImageLoader instance = null;

    private ImageLoader() {
    }

    public static ImageLoader getInstance() {
        if (instance == null) {
            synchronized (ImageLoader.class) {
                if (instance == null) {
                    instance = new ImageLoader();
                }
            }
        }
        return instance;
    }

    public void display(Context context, String url, ImageView imageView) {
        Glide.with(context)
                .load(url)
                .error(R.mipmap.image_loading)
                .placeholder(R.mipmap.image_loading)
                .dontAnimate()
                .into(imageView);

    }
    public void transformationsImage(Context context, String url, ImageView imageView) {
        Glide.with(context)
                .load(url)
               .error(R.mipmap.image_loading)
                .placeholder(R.mipmap.image_loading)
                .dontAnimate()
                .bitmapTransform(new RoundedCornersTransformation(context, 100, 0))
                .into(imageView);
    }





}
